package flash3.net
{
	import flash.utils.ByteArray;
	import flash.utils.Endian;
	public class ByteArrayPlus extends ByteArray
	{
		public function ByteArrayPlus()
		{
			super();
			this.endian = Endian.LITTLE_ENDIAN;
		}
		
		public function readString(parm1:uint, parm2:uint=0):String
		{
			var ret:String = readUTFBytes(parm1);
			if(parm2 != 0)
			{
				this.position += parm2-parm1;
			}
			return ret;
		}
		
		public function writeString(data:Object,multiByte:Boolean = false):void
		{
			if (multiByte)
			{
				if(data.value)
				{
					writeMultiByte(data.value, "utf-8");  	// 指定字符编码集
				}
			}
			else
			{
				if(data.value)
					writeUTFBytes(data.value);
				if(data.length)
					this.position += data.length-data.value.length;
			}
		}
		
//		public function clear():void
//		{
//			this.length = 0;
//		}
	}
}